<?php

namespace App\Http\Controllers\Customer\Api;

use App\Facades\UserService;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;

class UserController extends Controller
{
	public function updateUserInfo(Request $request)
	{
		$rules = [
			'name' => 'required',
			'sex' => 'required',
			'phone' => 'required|telephone',
			'installation_address' => 'required',
		];
		$this->validate($request, $rules);

		UserService::updateUserInfo($request->only([
			'name',
			'sex',
			'phone',
			'installation_address',
			]));
		return formatJsonResponse();
	}

    public function addAfterService(Request $request)
    {
        $rules = [
            'equipment_failure' => 'required',
            'failure_description' => 'required',
            'door_to_door_service' => 'required',
            'name' => 'required',
            'phone' => 'required|telephone',
            'installation_address' => 'required',
        ];
        $this->validate($request, $rules);

        UserService::addAfterService($request->only([
                'equipment_failure',
                'failure_description',
                'door_to_door_service',
                'name',
                'phone',
                'installation_address',
            ]));
        return formatJsonResponse();
    }
}
